package com.yanchengtect.demo.progress.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* @author 文心雕龙 Email：xuwenlong@shike8888.com
* @version 创建时间：2018年9月6日 下午4:48:11
* 类说明
*/
public class YCStringUtil {

	/**
	 * 驼峰式字符串转下划线字符串
	 * @param line 源字符串
	 * @return
	 */
    public static String camel2Underline(String line) {
        if (line == null || "".equals(line)) {
            return "";
        }
        Pattern pattern = Pattern.compile("[A-Z]");
        Matcher matcher = pattern.matcher(line);
        while (matcher.find()) {
            String word = matcher.group();
            line = line.replaceFirst(word, "_"+word.toLowerCase());
        } 
    	return line;
    }
}
